#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repp(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, l, r) for(int i = l; i <= r; ++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const int N = 200005;
int n, m;
ll L, V;
ll d[N], v[N], a[N];
ll p[N];
vector<pair<int, int> > req;
bool cmp(pair<int, int> x, pair<int, int> y) {
    return x.se < y.se;
}
void SOLVE() {
    req.clear();
    cin >> n >> m >> L >> V;
    rep(i, n) cin >> d[i] >> v[i] >> a[i];
    rep(i, m) cin >> p[i];
    sort(p, p + m);
    rep(i, n) {
        if(a[i] == 0) {
            if(v[i] <= V) continue;
            else {
                int k = lower_bound(p, p + m, d[i]) - p;
                if(k < m) req.pb(mp(k, m - 1));
            }
        }
        if(a[i] > 0) {
            if(v[i] > V) {
                int k = lower_bound(p, p + m, d[i]) - p;
                if(k < m) req.pb(mp(k, m - 1));
            }
            else {
                int l = 0, r = m - 1, mid, k = m;
                while(l <= r) {
                    mid = (l + r) / 2;
                    if(2ll * a[i] * (p[mid] - d[i]) > V * V - v[i] * v[i])
                        k = mid, r = mid - 1;
                    else l = mid + 1;
                }
                if(k < m) req.pb(mp(k, m - 1));
            }
        }
        if(a[i] < 0) {
            if(v[i] <= V) continue;
            else {
                int tmp = lower_bound(p, p + m, d[i]) - p;
                int l = tmp, r = m - 1, mid, k = m;
                while(l <= r) {
                    mid = (l + r) / 2;
                    if(2ll * a[i] * (p[mid] - d[i]) > V * V - v[i] * v[i])
                        k = mid, l = mid + 1;
                    else r = mid - 1;
                }
                if(k < m) req.pb(mp(tmp, k));
            }
        }
    }
    if(req.empty()) {
        cout << 0 << ' ' << m << endl;
        return;
    }
    int sz = req.size();
    cout << sz << ' ';
    sort(req.begin(), req.end(), cmp);
    int lst = -1, cnt = 0;
    rep(i, sz) {
        if(lst < req[i].fi) 
            lst = req[i].se, cnt++;
    }
    cout << m - cnt << endl;
}
int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T;
    cin >> T;
    while(T--) SOLVE();
    return 0;
}